package cc.gu.tank;

import cc.gu.tank.scene.GameOver;
import cc.gu.tank.scene.GameScene;
import cc.gu.tank.scene.Index;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

/**
 * @Author: GuSongLiao
 * @Date: 2025/9/29 8:53
 * @Description: 导演类，负责切换场景，调度全局
 */
public class Director {

    public static final double WIDTH = 960;
    public static final double HEIGHT = 640;

    private static Director instance = new Director();

    private Stage stage;

    private Director() {
    }

    public static Director getInstance() {
        return instance;
    }

    /**
     * 初始化
     * @param stage
     */
    public void init(Stage stage) {
        AnchorPane root = new AnchorPane();
        Scene scene = new Scene(root, WIDTH, HEIGHT);
        stage.setScene(scene);
        stage.getIcons().add(new Image("image/logo.png"));

        this.stage = stage;
        Index.init(stage);
        stage.show();
    }

    /**
     * 开始游戏
     */
    public void gameStart() {
        new GameScene().init(stage);
    }

    /**
     * 结束游戏
     */
    public void gameOver() {
        GameOver.init( stage);
    }
}
